import { post_with_json, post_without_params } from './HttpMethod';
import { getOrGenerateDeviceId } from '../utils/deviceId';

export function login(params: any) {
  // 添加设备ID到登录参数
  const loginParams = {
    ...params,
    frontendDeviceId: getOrGenerateDeviceId(),
  };
  return post_with_json('api/user/login', loginParams);
}

export function register(params: any) {
  // 添加设备ID到注册参数
  const registerParams = {
    ...params,
    frontendDeviceId: getOrGenerateDeviceId(),
  };
  return post_with_json('api/user/register', registerParams);
}

export function logout() {
  return post_without_params('api/user/logout');
}

export function forgetPassword(params:any){
  return post_with_json("api/user/up/passwd",params)
}